import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import { getUserInfoRequest } from '@/api/user'

export const useUserStore = defineStore('user', () => {
  const userInfo = ref(null)
  const setUserInfo = (info) => {
    userInfo.value = {
      userId: info.userId,
      userName: info.userName
    }
  }
  const getUserInfo = async () => {
    const res = await getUserInfoRequest()
    setUserInfo(res.data)
  }

  return {
    userInfo,
    getUserInfo,
    setUserInfo
  }
}, {
  persist: false
})